class Link < ActiveRecord::Base

  validates :url, presence: true

  before_save :parse_html

  private

  def parse_html
    response = RestClient.get(url)
    obj = Nokogiri::HTML(response)
    self.title = obj.css('title').text
    self.content = obj.css('body').text
  end
end
